package com.zbw;

import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Collection;

public class ThreadRunnable implements Runnable {
    static Boolean flag = true;
    public static void main(String args[]) throws InterruptedException {
        Thread tm=new Thread(new ThreadRunnable());
        tm.start();
        for(int i=0;i<2000;i++){
            System.out.println("执行main方法-----------------");
            if(i==1000){   Thread.sleep(10);      }
            if(i==1999){
                stop();
                break;
            }
        }
    }
    static public void stop(){
        flag=false;
        System.out.println("停止执行run方法");
    }
    @Override
    public void run(){
        for(int i=0;i<2000;i++){
            if(!flag){
                break;
            }
            System.out.println("执行run方法");
        }
    }
}
